// 导入请求模块
import http from "../utils/request";
// 导入声明文件
import type { ArticleSubmitTypeAPI, ArticleFilterType } from "../types/article";

// 获取文章频道列表API
export const getChannelListAPI = () => {
  return http({
    url: "/channels",
    method: "get",
  });
};

// 提交文章API
export const addArticleAPI = (data: ArticleSubmitTypeAPI) => {
  return http({
    url: "mp/articles?draft=false",
    method: "post",
    data,
  });
};

// 获取文章列表API
export const getArticleListAPI = (params: ArticleFilterType) => {
  return http({
    url: "mp/articles",
    method: "get",
    params,
  });
};

// 删除文章api
export const delArticleAPI = (id: string) => {
  return http({
    url: `mp/articles/${id}`,
    method: "delete",
  });
};

// 编辑获取文章详情api
export const reGetArticleListAPI = (ArticleId: string) => {
  return http({
    url: `mp/articles/${ArticleId}?draft=false`,
    method: "get",
  });
};

// 编辑更新文章api
export const putArticleAPI = (target: string, data: ArticleSubmitTypeAPI) => {
  return http({
    url: `mp/articles/${target}`,
    method: "put",
    data,
  });
};
